import React from 'react';
import ReactDOM from 'react-dom';
import 'antd-mobile/dist/antd-mobile.css'; 
import App from './App';
import "./gloabal_css/gloabal.css";
/**
 * 
 */
import { createStore , applyMiddleware , compose } from 'redux';
import thunk from 'redux-thunk';
import { Provider } from 'react-redux';
import { BrowserRouter as Router , Route, Switch} from 'react-router-dom';

import reducers from './redux/reducer.js';
import './axios.config.js';
import axios from "axios";
// views
// import Test from './views/test/Test';
import AuthRouter from './components/authrouter/AuthRouter';
import Login from './views/login/Login';
import Regist from './views/regist/Regist';
import JobhunterInfo from './views/jobhunter_info/jobhunterinfo';
import BossInfo from './views/boss_info/bossinfo.js';
import Main from "./views/main/Main";
import Chat from "./views/chat/Chat";

import NotFound from "./views/notfound/NotFound";
const store = createStore(reducers, compose(
    applyMiddleware(thunk)
))

/**
 * import { browserHistory } from 'react-router'
 * <Router history={browserHistory} routes={routes} ></Router>
 * 服务器配置
 * 服务器需要做好处理 URL 的准备。
 * 处理应用启动最初的 / 这样的请求应该没问题，
 * 但当用户来回跳转并在 /accounts/123 刷新时，
 * 服务器就会收到来自 /accounts/123 的请求，
 * 这时你需要处理这个 URL 并在响应中包含 JavaScript 应用代码。
 * // 通常用于加载静态资源
 *  app.use(express.static(__dirname + '/public'))
 * app.get('*', function (request, response){
 *      response.sendFile(path.resolve(__dirname, 'public', 'index.html'))
 * })
 */
ReactDOM.render((
    <Provider store={store}>
        <Router onUpdate={() => window.scrollTo(0, 0)}>
            <div>
                <AuthRouter></AuthRouter>
                <Switch>
                  <Route path='/' exact component={App}></Route>
                  <Route path='/login' component={Login}></Route>
                  <Route path='/regist' component={Regist}></Route>
                  <Route path='/jobhunterinfo' component={JobhunterInfo}></Route>
                  <Route path='/bossinfo' component={BossInfo}></Route>
                  <Route path="/chat/:userId" component={Chat}></Route>
                  <Route  component={Main}></Route>
                  {/* <Route  path="/main" component={Main}></Route> 作为一级路由也行 */}
                  <Route component={NotFound}></Route>
                 
                </Switch>
            </div>
        </Router>
    </Provider>
), document.getElementById('root'));

/**
 * 上面我们讨论的路由配置可以被写成下面这个样子：
const routeConfig = [
  { path: '/',
    component: App,
    indexRoute: { component: Dashboard },
    childRoutes: [
      { path: 'about', component: About },
      { path: 'inbox',
        component: Inbox,
        childRoutes: [
          { path: '/messages/:id', component: Message },
          { path: 'messages/:id',
            onEnter: function (nextState, replaceState) {
              replaceState(null, '/messages/' + nextState.params.id)
            }
          }
        ]
      }
    ]
  }
]

React.render(<Router routes={routeConfig} />, document.body);
 * 
 */


//  git test